<template>
  <div>
    <div style="padding:15px">
      <el-button type="primary" @click="handleShowChapterDialog">
        添加章节
      </el-button>
      <el-button :disabled="btnPrevDisabled" type="primary" @click="prev">
        上一步
      </el-button>
      <el-button :disabled="btnNextDisabled" type="primary" @click="next">
        保存并下一步
      </el-button>
      <chapter-form ref="chapterFormDialog"/>
    </div>
  </div>
</template>
<script>
import ChapterForm from '@/views/course/components/CourseChapter/chapterForm'
import chapterApi from '@/api/chapter'
export default{
  components: {
    ChapterForm
  },
  data() {
    return {
      chapters: [],
      btnPrevDisabled: false,
      btnNextDisabled: false
    }
  },
  created() {
    this.getChapters()
  },
  methods: {
    getChapters() {
      chapterApi.getChapters(this.$parent.courseId).then(r => {
        this.chapters = r.data.items
      })
    },
    handleShowChapterDialog() {
      // console.log(this.$parent)
      // console.log(this.$parent.$parent)
      // this.dialogFormVisible = true
      this.$refs.chapterFormDialog.title = '新增章节'
      this.$refs.chapterFormDialog.chapter = {}
      this.$refs.chapterFormDialog.dialogFormVisible = true
    },
    prev() {
      this.btnPrevDisabled = true
      this.$parent.active = 0
    },
    next() {
      this.btnNextDisabled = true
      this.$parent.active = 2
    }
  }
}
</script>
//六分半
